package com.lagou.homework3.no4;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class StudentMain {

    public static void main(String[] args) {
        //新增学生信息
        Scanner sc = new Scanner(System.in);
        List list = new ArrayList();
        //循环新增4名学生信息
        for(int i=0;i<4;i++){
            Student stu = new Student();
            System.out.println("请输入学生id：");
            int id = sc.nextInt();
            stu.setId(id);
            System.out.println("请输入学生姓名：");
            String name = sc.next();
            stu.setName(name);
            System.out.println("请输入学生年龄：");
            int age = sc.nextInt();
            stu.setAge(age);
            AddStudent.add(list,stu);
        }
        SelectStudent.select(list);
        System.out.println("============================================");
        //删除学生信息
        System.out.println("请输入要删除的学生学号：");
        int reId = sc.nextInt();
        RemoveStudent.remove(list,reId);
        SelectStudent.select(list);
        System.out.println("============================================");
        //修改学生信息
        Student upstu  = new Student();
        System.out.println("请输入要修改的学生学号：");
        int upId = sc.nextInt();
        upstu.setId(upId);
        System.out.println("请选择要修改的学生信息：1、姓名；2、年龄；3、全部");
        int sel = sc.nextInt();
        if(sel==1){
            System.out.println("请输入要修改的学生姓名：");
            String upname = sc.next();
            upstu.setName(upname);
        }
        if(sel==2){
            System.out.println("请输入要修改的学生年龄：");
            int upage = sc.nextInt();
            upstu.setAge(upage);
        }
        if(sel==3){
            System.out.println("请输入要修改的学生姓名：");
            String upname = sc.next();
            upstu.setName(upname);
            System.out.println("请输入要修改的学生年龄：");
            int upage = sc.nextInt();
            upstu.setAge(upage);
        }
        UpdateStudent.update(list,upstu);
        SelectStudent.select(list);
        System.out.println("============================================");
    }
}
